<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends MY_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('page_model');
		$this->load->model('article_model');
		$this->load->model('gallery_model');
		$this->load->model('coltypes_model');
	}
	
	public function index($page=1){
		$value=!empty($_GET['search'])?$_GET['search']:'';
		$data['schVal']=$value;
		if($value!=''){
			/*分页*/
			$config['query_string_segment'] = 'p';
			$config['base_url'] = SITE_URL.'/search/index?search='.$value;//分页地址
			$config['uri_segment'] = 4;//页码所在URI段
			$config['page_query_string'] = TRUE;
			if(isset($_GET['p'])&&$_GET['p']){
				$page=$_GET['p'];
			}else{
				$page=1;
			}
			//计算当前页面新闻总条数
			$test=$this->db->query("SELECT * FROM boc_article where title like '%$value%' AND audit = 1 AND (cid = 2 OR cid = 3 OR cid = 4 OR cid = 5 OR cid = 6) ORDER BY sort_id desc")->result_array();
			//$con=count($test);
			//$where=array('title like'=>"%".$value."%",'in'=>array('cid',array('4','12','43','47','96','69','63','97')),'audit'=>1);//定义SQLwhere条件保存到
			//$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
			$config['total_rows']=count($test);
			$config['per_page'] = 5;//每页显示的条数
			$config['use_page_numbers'] = TRUE;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
			$config['cur_tag_open']= '<a class="active">';
			$config['cur_tag_close']='</a>';
			$config['full_tag_open'] = '<div class="page">';
			$config['full_tag_close'] = '</div>';
			$config['last_link'] = false;
			$config['first_link']= false;
			$config['num_links']=5;
			$config['cur_tag_open']='<a href="#" class="active">';
			$config['cur_tag_close']='</a>';
			$config['prev_link']='<';
			$config['next_link']='>';
			$config['num_tag_open']='';
			$config['num_tag_close']='';
			$config['prev_tag_open']='';
			$config['prev_tag_close']='';
			$config['next_tag_open']='';
			$config['next_tag_close']='';
			$data['fenye']=$this->article_model->get_paging2($config,$page,$value);
		}
		$data['seo']=array('title'=>'Search');
		$this->load->view('search',$data);
	}
	
	
	
	
	
	
	
	
	
}